Function.RegisterNamespace("System.Script");

System.Script.DelayedConstructor=function(scope,constructor,callback,preloadArguments){
    if(!Object.IsType(Function,constructor))throw new Error("System.Script.DelayedConstructor: 'constructor' must be a valid Function pointer.");
    if(callback!=undefined&&!Object.IsType(Function,callback))throw new Error("System.Script.DelayedConstructor: 'callback' must be a valid Function pointer.");
    var args=Array.prototype.slice.call(preloadArguments||[],0);
    if(scope&&scope.constructor===constructor){
        if(callback)callback.apply(scope,args);
        return scope;
    }else{
        if(args&&args.length){
            return Function.GetDelegate.apply(Function,[constructor,scope].concat(args));
        }
        return constructor;
    }
}; 
